import 'Person.dart';

void main(){
  var student=new Student();
  student.study();

  student.name='Tom';
  student.age=23;
  student.work();
  print(student.isAdult);

  //多态
  var person=new Student();
  person.work();
  if(person is Student){
    person.study();
  }
}

class Student extends Person{
  void study(){
    print('Student Study.......');
  }

  /**
   * 重写父类计算属性
   */
  @override
  bool get isAdult => age>15;

  /**
   * 重写父类函数
   */
  @override
  void work() {
    super.work(); //调用父类函数
    print('Studnet work');
  }

  @override
  String toString() {
    // 也可以重写Object的toString方法
    return super.toString();
  }
}